package com.j.lemon.learn;

import org.jodconverter.OnlineConverter;
import org.jodconverter.document.DefaultDocumentFormatRegistry;
import org.jodconverter.office.OfficeManager;
import org.jodconverter.office.OfficeUtils;
import org.jodconverter.office.OnlineOfficeManager;
import org.jodconverter.ssl.SslConfig;

import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

/**
 * word转pdf
 */
public class WordToPdf2 {
    public static void main(String[] args) throws Exception {
        File inputFile = new File("/Users/lijunjun/Downloads/1592347878858874881_审计报告回归测试.docx");
        File outputFile = new File("1592347878858874881_审计报告回归测试1.pdf");
        String sourceFilePath = "/Users/lijunjun/Downloads/1592347878858874881_审计报告回归测试.docx";
        String targetFilePath = "/home/iamtest/1592347878858874881_审计报告回归测试1.pdf";
        final SslConfig sslConfig = new SslConfig();
        sslConfig.setEnabled(true);
        sslConfig.setTrustStore("/path/to/the/truststore.p12");
        sslConfig.setTrustStorePassword("Password of the TrustStore");
        final OfficeManager manager =
                OnlineOfficeManager.builder()
                        .urlConnection("http://10.28.149.247:8100")
                        .build();
        manager.start();
        OnlineConverter converter = OnlineConverter.builder().officeManager(manager).formatRegistry(DefaultDocumentFormatRegistry.getInstance()).build();
        converter.convert(new File(sourceFilePath)).to(new File(targetFilePath)).execute();
        manager.stop();

    }
}
